package com.shenzhen.horselive.presenter;


import io.reactivex.disposables.Disposable;

/**
 * 1、view如果为空，自动取消订阅
 * 2、view处于活跃状态，回调{@link #onNextInActive(Object)}
 *
 * @param <T>
 */
public abstract class LoadingViewObserver<T> extends ViewObserver<T> {
    private BaseView view;

    public LoadingViewObserver(BaseView view) {
        super(view);
        this.view = view;
    }

    @Override
    public void onComplete() {
        view.hideLoading();
    }

    @Override
    public void onSubscribe(Disposable d) {
        super.onSubscribe(d);
        if(view!=null) {
            view.showLoading();
        }
    }

    @Override
    public void onError(Throwable e) {
        super.onError(e);
        view.hideLoading();

    }


}